package springboot.util;

import javax.annotation.Resource;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

@Component
public class RedisUtil {
	@Resource
	private RedisTemplate<String, Object> redisTemplate;
	
	public boolean set(String key, Object obj) {
		ValueOperations<String, Object> vo = redisTemplate.opsForValue();
		vo.set(key, obj);
		return true;
	}
	
	public Object get(String key) {
		ValueOperations<String, Object> vo = redisTemplate.opsForValue();
		return vo.get(key);
	}
	
	public boolean exists(String key) {
		return redisTemplate.hasKey(key);
	}
}
